package com.ruoyi.web.controller.ufox;

import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ufox.domain.BisDeviceData;
import com.ruoyi.ufox.service.IBisDeviceDataService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 蔬菜机传感器数据Controller
 * 
 * @author ufoxs
 * @date 2022-08-16
 */
@RestController
@RequestMapping("/bussiness/data")
public class BisDeviceDataController extends BaseController
{
    @Autowired
    private IBisDeviceDataService bisDeviceDataService;

    /**
     * 查询蔬菜机传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:data:list')")
    @GetMapping("/list")
    public TableDataInfo list(BisDeviceData bisDeviceData)
    {
        startPage();
        List<BisDeviceData> list = bisDeviceDataService.selectBisDeviceDataList(bisDeviceData);
        return getDataTable(list);
    }

    /**
     * 导出蔬菜机传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:data:export')")
    @Log(title = "蔬菜机传感器数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisDeviceData bisDeviceData)
    {
        List<BisDeviceData> list = bisDeviceDataService.selectBisDeviceDataList(bisDeviceData);
        ExcelUtil<BisDeviceData> util = new ExcelUtil<BisDeviceData>(BisDeviceData.class);
        util.exportExcel(response, list, "蔬菜机传感器数据数据");
    }

    /**
     * 获取蔬菜机传感器数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:data:query')")
    @GetMapping(value = "/{dataId}")
    public AjaxResult getInfo(@PathVariable("dataId") Long dataId)
    {
        return AjaxResult.success(bisDeviceDataService.selectBisDeviceDataByDataId(dataId));
    }

    /**
     * 新增蔬菜机传感器数据
     */
    @PreAuthorize("@ss.hasPermi('bussiness:data:add')")
    @Log(title = "蔬菜机传感器数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BisDeviceData bisDeviceData)
    {
        return toAjax(bisDeviceDataService.insertBisDeviceData(bisDeviceData));
    }

    /**
     * 修改蔬菜机传感器数据
     */
    @PreAuthorize("@ss.hasPermi('bussiness:data:edit')")
    @Log(title = "蔬菜机传感器数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BisDeviceData bisDeviceData)
    {
        return toAjax(bisDeviceDataService.updateBisDeviceData(bisDeviceData));
    }

    /**
     * 删除蔬菜机传感器数据
     */
    @PreAuthorize("@ss.hasPermi('bussiness:data:remove')")
    @Log(title = "蔬菜机传感器数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dataIds}")
    public AjaxResult remove(@PathVariable Long[] dataIds)
    {
        return toAjax(bisDeviceDataService.deleteBisDeviceDataByDataIds(dataIds));
    }
}
